﻿//===============================================================================
// Microsoft Innovation Centre - Western Europe
// Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.WVB.Framework.DataServicesEntities;
using Microsoft.WVB.Framework.Interfaces;

namespace Microsoft.WVB.Services.MockServices
{
    public class TestData : IBroadcasterProvider
    {
        private int titleSeed = 1;
        private int durationSeed = 1;

        public Channel CreateRandomChannelSchedule(string Name, string IconPath)
        {
            Channel channel = new Channel();
            channel.Name = Name;
            channel.LongName = GetURLBase() + IconPath;
            channel.Icon = GetURLBase() + IconPath;

            DateTime dtCurrent = DateTime.Today;
            DateTime dtMax = DateTime.Today + TimeSpan.FromHours(23.59);

            while (dtCurrent <= dtMax)
            {
                Schedule s = new Schedule();
                Program p = new Program();

                s.start = dtCurrent;
                s.Duration = GetRandomDuration();
                channel.Schedules.Add(s);

                dtCurrent += TimeSpan.FromSeconds(s.Duration);
            }
            return channel;
        }

        private string GetRandomTitle()
        {
            string[] titles =
            {
                "World News",
                "Cash in the Attic",
                "Newsnight",
                "Top Gear",
                "Monty Python's Flying Circus",
                "You Are What You Eat",
                "How Not To Decorate",
                "Bargain Hunt",
                "How Clean Is Your House?",
                "Doctor Who",
                "Robin Hood",
                "Ramsay's Kitchen Nightmares",
                "Coupling",
                "Absolutely Fabulous",
                "Not Going Out",
                "Too Ugly To Love",
                "The Graham Norton Show",
                "Changing Rooms",
                "Britain's Worst Teeth",
                "Teenager",
                "The Office",
                "MI-5",
                "Rosie & Jim",
                "Andy Pandy",
                "The Brollys",
                "Angelmouse",
                "William's Wish Wellingtons",
                "Friends",
                "Last restaurant Standing",
                "Little Britain",
                "Life On Mars S2",
                "Eddie Izzard",
                "Spaced",
                "Primeval",
                "Torchwood",
                "Wire in the Blood",
                "The Human Spider",
                "The Cathrine Tate Show",
                "Hex",
                "Hotel Babylon",
                "Jekyll",
                "Ask the Punk Professor",
                "Brit Awards",
                "Talking Movies",
                "News"
            };

            Random randNum = new Random(titleSeed);
            titleSeed = randNum.Next(1, 45);
            return titles[titleSeed];
        }

        private int GetRandomDuration()
        {
            Random randNum = new Random(durationSeed);
            durationSeed = randNum.Next(1, 24) * 5 * 60;
            return (durationSeed);
        }

        public List<Broadcaster> CreateBroadcasterAndChannelList()
        {
            List<Broadcaster> _broadcasters = new List<Broadcaster>();

            Broadcaster b1 = new Broadcaster();
            b1.Name = "RTVE";
            b1.Country = GetURLBase() + "media/broadcasters/regional.png";
            b1.Icon = GetURLBase() + "media/broadcasters/regional.png";
            b1.Channels = new Collection<Channel>();
            b1.Channels.Add(CreateChannel("TVE 1", "media/channels/TVE1.png"));
            b1.Channels.Add(CreateChannel("TVE 2", "media/channels/TVE2.png"));
            b1.Channels.Add(CreateChannel("24H TVE", "media/channels/24HTVE.png"));
            b1.Channels.Add(CreateChannel("Clean TVE", "media/channels/ClanTVE.png"));
            b1.Channels.Add(CreateChannel("Teledeporte", "media/channels/Teledeporte.png"));
            _broadcasters.Add(b1);

            Broadcaster b2 = new Broadcaster();
            b2.Name = "Telecinco";
            b2.Country = GetURLBase() + "media/broadcasters/orange.png";
            b2.Icon = GetURLBase() + "media/broadcasters/orange.png";
            b2.Channels = new Collection<Channel>();
            b2.Channels.Add(CreateChannel("Telecinco", "media/channels/Telecinco.png"));
            b2.Channels.Add(CreateChannel("Telecinco Sport", "media/channels/TelecincoSport.png"));
            b2.Channels.Add(CreateChannel("Telecinco Estrellas", "media/channels/TelecincoEstrellas.png"));
            _broadcasters.Add(b2);

            Broadcaster b3 = new Broadcaster();
            b3.Name = "Antena 3";
            b3.Country = GetURLBase() + "media/broadcasters/cuatro.png";
            b3.Icon = GetURLBase() + "media/broadcasters/cuatro.png";
            b3.Channels = new Collection<Channel>();
            b3.Channels.Add(CreateChannel("Antena 3", "media/channels/Antena3.png"));
            b3.Channels.Add(CreateChannel("Antena Neox", "media/channels/antena_neox.png"));
            b3.Channels.Add(CreateChannel("Antena Nova", "media/channels/antena_nova.png"));
            _broadcasters.Add(b3);


            Broadcaster b4 = new Broadcaster();
            b4.Name = "Sogecable";
            b4.Country = GetURLBase() + "media/broadcasters/cuatro2.png";
            b4.Icon = GetURLBase() + "media/broadcasters/cuatro2.png";
            b4.Channels = new Collection<Channel>();
            b4.Channels.Add(CreateChannel("Cuatro", "media/channels/cautro.png"));
            b4.Channels.Add(CreateChannel("CNN", "media/channels/cnn.png"));
            b4.Channels.Add(CreateChannel("40 Latino", "media/channels/40Latino.png"));
            _broadcasters.Add(b4);


            Broadcaster b5 = new Broadcaster();
            b5.Name = "LaSexta";
            b5.Country = GetURLBase() + "media/broadcasters/lasexta.png";
            b5.Icon = GetURLBase() + "media/broadcasters/lasexta.png";
            b5.Channels = new Collection<Channel>();
            b5.Channels.Add(CreateChannel("La Sexta", "media/channels/lasexta.png"));
            b5.Channels.Add(CreateChannel("Hogar 10", "media/channels/Hogar10.png"));
            _broadcasters.Add(b5);


            Broadcaster b6 = new Broadcaster();
            b6.Name = "Veo";
            b6.Country = GetURLBase() + "media/broadcasters/veo.png";
            b6.Icon = GetURLBase() + "media/broadcasters/veo.png";
            b6.Channels = new Collection<Channel>();
            b6.Channels.Add(CreateChannel("Veo", "media/channels/veo.png"));
            b6.Channels.Add(CreateChannel("SETenVeo", "media/channels/setenveo.png"));
            _broadcasters.Add(b6);


            Broadcaster b7 = new Broadcaster();
            b7.Name = "NetTV";
            b7.Country = GetURLBase() + "media/broadcasters/nettv.png";
            b7.Icon = GetURLBase() + "media/broadcasters/nettv.png";
            b7.Channels = new Collection<Channel>();
            b7.Channels.Add(CreateChannel("NetTV", "media/channels/NetTV.png"));
            b7.Channels.Add(CreateChannel("Fly Music", "media/channels/FlyMusic.png"));
            _broadcasters.Add(b7);

            Broadcaster b8 = new Broadcaster();
            b8.Name = "Cuatro5";
            b8.Country = GetURLBase() + "media/broadcasters/cuatro5.png";
            b8.Icon = GetURLBase() + "media/broadcasters/cuatro5.png";
            b8.Channels = new Collection<Channel>();
            b8.Channels.Add(CreateChannel("NetTV", "media/channels/NetTV.png"));
            b8.Channels.Add(CreateChannel("Fly Music", "media/channels/FlyMusic.png"));
            _broadcasters.Add(b8);



            return _broadcasters;
        }

        public Channel CreateChannel(string Name, string Path)
        {
            Channel channel = new Channel();
            channel.Name = Name;
            channel.LongName = GetURLBase() + Path;
            channel.Icon = GetURLBase() + Path;
            return channel;
        }

        protected string GetURLBase()
        {
            string str = System.Windows.Application.Current.Host.Source.OriginalString;
            return str.Substring(0, str.LastIndexOf("/")).Replace("ClientBin", string.Empty);
        }

    }
}
